package com.smyh.commcache.commd;

import com.smyh.protcol.device.CMDUtil;

import org.apache.mina.core.buffer.IoBuffer;

public class UIParamOptionUtil {

	/**
	 * 
	 * @param chooseIndex 选中某类参数后，要修改某个参数序列号
	 * @return
	 */
	public static IoBuffer writeDeviceParm(byte[] addrs,int paramType,int chooseIndex,int value) {

		byte[] sendByte = new byte[20];
		sendByte[0] = 0;
		switch (paramType) {
			case 1: {
				sendByte[0] = (byte) chooseIndex;
				break;
			}
			case 2: {

				sendByte[0] = (byte) (chooseIndex+10);
				break;
			}
			case 3:{

				sendByte[0] = (byte) (chooseIndex+21);
				break;
			}
			case 4:{
				sendByte[0] = (byte) (chooseIndex+33);
				break;
			}
			case 5:{
				sendByte[0] = (byte) (chooseIndex+50);
				break;
			}
			case 6:{
				//参数四不能修改：6使用参数4的序号
				sendByte[0] = (byte) (chooseIndex+33);
				break;
			}
		default:
			break;
		}

		sendByte[1] = (byte) value;
		sendByte[2] = (byte) (value/256);
		
		IoBuffer buf1 = CMDUtil.setOutParam(addrs, sendByte);
		return buf1;
	}

}
